package com.mifan.mapper;

import com.mifan.entity.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单表 Mapper 接口
 * </p>
 *
 * @author Milan
 * @since 2024-09-13
 */
public interface MenuMapper extends BaseMapper<Menu> {


    @Select("SELECT * FROM ums_menu WHERE type = 'M' ORDER BY sort")
    List<Menu> getMenuListByTypeMAndSort();

    @Select("SELECT * FROM ums_menu WHERE type = 'C' ORDER BY sort")
    List<Menu> getMenuListByTypeCAndSort();


    @Select("SELECT m.* FROM ums_menu m\n" +
            "        JOIN ums_role_menu rm ON m.id = rm.menu_id\n" +
            "WHERE rm.role_id = ${roleid}")
    List<Menu> getMenuListByRoleId(Long roleid);
}
